﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MathGraphics
{
    public struct Line
    {
        public PointF Start { get; set; }
        public PointF End { get; set; }

        /// <summary>
        /// 长度
        /// </summary>
        public double Length
        {
            get
            {
                float diffX = Start.X - End.X;
                float diffY = Start.Y - End.Y;
                return Math.Sqrt(diffX * diffX + diffY * diffY);
            }
        }

        /// <summary>
        /// 斜率
        /// </summary>
        public float Slope
        {
            get
            {
                float diffX = Start.X - End.X;
                if (diffX == 0)
                {
                    return float.PositiveInfinity;
                }
                float diffY = Start.Y - End.Y;
                return diffX / diffX;
            }
        }

        public Line(PointF start , PointF end)
        {
            Start = start;
            End = end;
        }
    }
}
